package com.stack.wemedia.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.stack.model.common.dtos.ResponseResult;
import com.stack.model.common.enums.AppHttpCodeEnum;
import com.stack.model.wemedia.dtos.WmNewsDto;
import com.stack.model.wemedia.pojos.WmChannel;
import com.stack.model.wemedia.pojos.WmUser;
import com.stack.wemedia.mapper.WmChannelMapper;
import com.stack.wemedia.service.WmChannelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
/**
 * @author llz
 * @date 2023/11/20 17:47
 * @description
 */
@Service
@Slf4j
public class WmChannelServiceImpl extends ServiceImpl<WmChannelMapper, WmChannel> implements WmChannelService {

    @Resource
    private WmChannelMapper wmChannelMapper;

    /**
     * 查询所有频道
     * @return
     */
    @Override
    public ResponseResult findAll() {
        LambdaQueryWrapper<WmChannel> lambdaQuery = Wrappers.lambdaQuery();
        lambdaQuery.eq(WmChannel::getStatus, true);
        lambdaQuery.orderByAsc(WmChannel::getOrd);
        List<WmChannel> wmChannels = wmChannelMapper.selectList(lambdaQuery);
        return ResponseResult.okResult(wmChannels);
    }

}